package com.caigou.modules.famous.widget

import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.view.Window
import android.widget.RadioButton
import android.widget.RadioGroup
import com.caigou.modules.famous.R

/**
 * @author #Suyghur.
 * Created on 2021/12/09
 */
class FamousFilterDialog(context: Context, private val sort: Int = 1) : Dialog(context) {

    lateinit var rgFamousFilter: RadioGroup
    lateinit var btnTotal: RadioButton
    lateinit var btnRate: RadioButton
    lateinit var btnNewest: RadioButton

    init {
        setCanceledOnTouchOutside(true)
        window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
        requestWindowFeature(Window.FEATURE_NO_TITLE)
        initView()
    }

    private fun initView() {
        setContentView(R.layout.dialog_famous_filter)
        rgFamousFilter = findViewById(R.id.famous_filter_rg_selector)
        btnTotal = findViewById(R.id.famous_filter_btn_total)
        btnRate = findViewById(R.id.famous_filter_btn_rate)
        btnNewest = findViewById(R.id.famous_filter_btn_newest)
        when (sort) {
            1 -> {
                btnTotal.isChecked = true
                btnRate.isChecked = false
                btnNewest.isChecked = false
            }
            2 -> {
                btnTotal.isChecked = false
                btnRate.isChecked = true
                btnNewest.isChecked = false
            }
            3 -> {
                btnTotal.isChecked = false
                btnRate.isChecked = false
                btnNewest.isChecked = true
            }
        }
    }
}